using ASP;
using HoWave.Common;
using HoWave.Data;
using HoWave.Web;
using HoWave.Web.Admin;
using System;
using System.Collections;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using Wuqi.Webdiyer;
public class HL_Admin_Admin_ListComment : Admin, IRequiresSessionState
{
	protected TextBox TextBox_Content;
	protected Button Button_Search;
	protected DropDownList DropDownList_State;
	protected GridView GridView_Comment;
	protected AspNetPager AspNetPager1;
	protected Button Button_Delete;
	protected Button Button_Success;
	protected Button Button_Error;
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			this.ViewState["Level"] = "";
			this.ViewState["State"] = "2";
			this.CommentBind("", "", 0, 0, 2);
		}
	}
	protected void CommentBind(string Level, string Content, int ShopID, int ProductID, int State)
	{
		this.ViewState["Level"] = Level;
		this.ViewState["State"] = State;
		Hashtable hashtable = new Hashtable();
		hashtable.Add("tblName", " [HLShop_Comment] as C,[HLShop_Product] as P,[HLShop_Shop] as S");
		hashtable.Add("seleName", "C.Id,C.UserName,P.ProductName,C.[DateTime],C.[Level],C.State,C.[Content],C.ShopID,C.ProductID");
		hashtable.Add("fldName", "DateTime");
		hashtable.Add("PageSize", 8);
		hashtable.Add("PageIndex", this.AspNetPager1.CurrentPageIndex);
		hashtable.Add("IsCount", 0);
		hashtable.Add("OrderType", 1);
		string text = "S.ShopID=C.ShopID AND C.ShopID=P.ShopID AND C.ProductID=P.ProductID ";
		if (Level != "")
		{
			text = text + " AND Level in (" + Level + ")";
		}
		if (Content != "")
		{
			text = text + " AND (Content LIKE '%" + Content + "%')  ";
		}
		if (State != 2)
		{
			text = text + "  AND State= " + State;
		}
		hashtable.Add("strWhere", text);
		Pager pager = new Pager();
		this.GridView_Comment.DataSource = pager.Query(hashtable);
		this.GridView_Comment.DataBind();
		this.AspNetPager1.AlwaysShow = true;
		this.AspNetPager1.PageSize = 8;
		hashtable.Remove("IsCount");
		hashtable.Add("IsCount", 1);
		this.AspNetPager1.RecordCount = pager.QueryRecordCount(hashtable);
	}
	protected void GridView_Comment_RowCommand(object sender, GridViewCommandEventArgs e)
	{
		if (e.CommandName == "_Delete")
		{
			Shop_Comment shop_Comment = new Shop_Comment();
			if (shop_Comment.DeleteComment(Convert.ToInt32(e.CommandArgument)))
			{
				this.WriteErrMsg("", "删除成功！", "Admin_ListComment.aspx");
			}
			else
			{
				this.WriteErrMsg("", "删除失败！", "Admin_ListComment.aspx");
			}
		}
	}
	protected void DropDownList_State_SelectedIndexChanged(object sender, EventArgs e)
	{
		this.CommentBind(this.ViewState["Level"].ToString(), this.TextBox_Content.Text.Trim(), 0, 0, int.Parse(this.DropDownList_State.SelectedValue));
	}
	protected void Button_Search_Click(object sender, EventArgs e)
	{
		this.CommentBind(this.ViewState["Level"].ToString(), this.TextBox_Content.Text.Trim(), 0, 0, int.Parse(this.DropDownList_State.SelectedValue));
	}
	protected void AspNetPager1_PageChanged(object sender, EventArgs e)
	{
		this.CommentBind(this.ViewState["Level"].ToString(), "", 0, 0, Convert.ToInt32(this.ViewState["State"]));
	}
	protected void UserButtonOnCommon(object sender, CommandEventArgs e)
	{
		Shop_Comment shop_Comment = new Shop_Comment();
		string commandName = e.CommandName;
		if (commandName != null)
		{
			if (!(commandName == "_Delete"))
			{
				if (!(commandName == "_Success"))
				{
					if (commandName == "_Error")
					{
						if (base.Request["id"] != null && base.Request["id"] != string.Empty && base.Request["id"].ToString() != "")
						{
							string str = base.Request["id"].ToString();
							string sql = "UPDATE [HLShop_Comment] SET [State] = 0 WHERE [Id] IN(" + str + ")";
							bool flag = this.conn.Execute(sql) >= 1;
							if (flag)
							{
								this.WriteSuccessMsg("", Language.GetAdminMsg("Common/CheckSuccess"), "Admin_ListComment.aspx");
							}
						}
					}
				}
				else
				{
					if (base.Request["id"] != null && base.Request["id"] != string.Empty && base.Request["id"].ToString() != "")
					{
						string str = base.Request["id"].ToString();
						string sql = "UPDATE [HLShop_Comment] SET [State] = 1 WHERE [Id] IN(" + str + ")";
						bool flag = this.conn.Execute(sql) >= 1;
						if (flag)
						{
							this.WriteSuccessMsg("", Language.GetAdminMsg("Common/CheckSuccess"), "Admin_ListComment.aspx");
						}
					}
				}
			}
			else
			{
				if (base.Request["id"] != null || base.Request["id"] != string.Empty)
				{
					string str = base.Request["id"].ToString();
					string sql = "DELETE FROM [HLShop_Comment] WHERE [Id] IN(" + str + ")";
					bool flag = this.conn.Execute(sql) >= 1;
					if (flag)
					{
						this.WriteSuccessMsg("", Language.GetAdminMsg("Common/DeleteSuccess"), "Admin_ListComment.aspx");
					}
				}
			}
		}
	}
}
